package net.apexes.demo.codegen.dslite.qvar;

import java.math.BigDecimal;
import net.apexes.demo.codegen.dslite.entity.GoodsComboItem;
import net.apexes.demo.codegen.dslite.qvar.base.QEntityBase;
import net.wafo.dslite.core.info.ForeignKey;
import net.wafo.dslite.core.info.Index;

import net.wafo.dslite.core.dsl.*;

/**
 * QGoodsComboItem is a DSLite query type for GoodsComboItem
 * @see GoodsComboItem
 */
public class QGoodsComboItem extends QEntityBase<GoodsComboItem> {

    public static final QGoodsComboItem $ = new QGoodsComboItem("GOODS_COMBO_ITEM");

    public final StringColumn goodsComboGroupId = varchar("GOODS_COMBO_GROUP_ID", 22).field("goodsComboGroupId").notNull().build();

    public final StringColumn parentGoodsId = varchar("PARENT_GOODS_ID", 22).field("parentGoodsId").notNull().build();

    public final StringColumn childGoodsId = varchar("CHILD_GOODS_ID", 22).field("childGoodsId").notNull().build();

    public final NumberColumn<BigDecimal> price = decimal("PRICE", 12, 3).field("price").notNull().build();

    public final StringColumn templateId = varchar("TEMPLATE_ID", 22).field("templateId").notNull().build();

    public class Indexs {

        public final Index constraintIndex36 = index("CONSTRAINT_INDEX_36").column(childGoodsId).build();

        public final Index constraintIndex367 = index("CONSTRAINT_INDEX_367").column(parentGoodsId).build();

        public final Index constraintIndex3678 = index("CONSTRAINT_INDEX_3678").column(goodsComboGroupId).build();

        public final Index primaryKey36 = index("PRIMARY_KEY_36").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraint367 = foreignKey(childGoodsId, "GOODS", "ID");

        public final ForeignKey constraint3678 = foreignKey(parentGoodsId, "GOODS", "ID");

        public final ForeignKey constraint3678d = foreignKey(goodsComboGroupId, "GOODS_COMBO_ITEM_GROUP", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QGoodsComboItem(String tableName) {
        super(GoodsComboItem.class, tableName);
    }

    @Override
    public GoodsComboItem newEntity() {
        return new GoodsComboItem();
    }

    @Override
    public Object getFieldValue(GoodsComboItem entity, String fieldName) {
        switch (fieldName) {
            case "goodsComboGroupId":
                return entity.getGoodsComboGroupId();
            case "parentGoodsId":
                return entity.getParentGoodsId();
            case "childGoodsId":
                return entity.getChildGoodsId();
            case "price":
                return entity.getPrice();
            case "templateId":
                return entity.getTemplateId();
            default:
                return super.getFieldValue(entity, fieldName);
        }
    }

    @Override
    public void setFieldValue(GoodsComboItem entity, String fieldName, Object value) {
        switch (fieldName) {
            case "goodsComboGroupId":
                entity.setGoodsComboGroupId((java.lang.String) value);
                break;
            case "parentGoodsId":
                entity.setParentGoodsId((java.lang.String) value);
                break;
            case "childGoodsId":
                entity.setChildGoodsId((java.lang.String) value);
                break;
            case "price":
                entity.setPrice((java.math.BigDecimal) value);
                break;
            case "templateId":
                entity.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setFieldValue(entity, fieldName, value);
                break;
        }
    }

}

